﻿using System;
using System.Collections.ObjectModel;
using System.Windows.Data;
using System.Windows.Controls;

namespace Inspire.ValueConverters
{
    public class ErrorContentConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var errors = value as ReadOnlyObservableCollection<ValidationError>;

            if (errors == null || errors.Count < 1)
            {
                return "";
            }

            return errors[0].ErrorContent;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
